package supimpa.src;
import static org.lwjgl.opengl.GL11.*;

public class CommonRenders {

	public static Render normalBlock = new Render(){
		
		int dl;
		public void init(){
			
			dl = glGenLists(1);
			glNewList(dl, GL_COMPILE);
			
			createCube(1f);
			
			glEndList();
		}
		
		public void render(int[] position, int meta, int texture) {
			
			glPushMatrix();

			glTranslatef(position[0], position[1], position[2]);
			glCallList(dl);
			
			glPopMatrix();
		}};
		
		
		
		private static void tex(float x, float y){
			
			glTexCoord2f(x/256f, y/256f);
		}
		
		private static void createCube(float size){
			
			float t = (1*16); //coluna
			
			float t2 = 0; //linha
			
			glBegin(GL_QUADS);
			
			tex(t, t2);			glVertex3f(0-size/2, 0+size/2, 0+size/2);
			tex(t+16, t2);			glVertex3f(0-size/2, 0+size/2, 0-size/2);
			tex(t+16, t2+16);			glVertex3f(0-size/2, 0-size/2, 0-size/2);
			tex(t, t2+16);			glVertex3f(0-size/2, 0-size/2, 0+size/2);
			
			tex(t, t2);			glVertex3f(0+size/2, 0+size/2, 0+size/2);
			tex(t+16, t2);			glVertex3f(0+size/2, 0+size/2, 0-size/2);
			tex(t+16, t2+16);			glVertex3f(0+size/2, 0-size/2, 0-size/2);
			tex(t, t2+16);			glVertex3f(0+size/2, 0-size/2, 0+size/2);
			
			tex(t, t2);			glVertex3f(0-size/2, 0+size/2, 0+size/2);
			tex(t+16, t2);			glVertex3f(0+size/2, 0+size/2, 0+size/2);
			tex(t+16, t2+16);			glVertex3f(0+size/2, 0-size/2, 0+size/2);
			tex(t, t2+16);			glVertex3f(0-size/2, 0-size/2, 0+size/2);
	    	
			tex(t, t2);			glVertex3f(0-size/2, 0+size/2, 0-size/2);	
			tex(t+16, t2);			glVertex3f(0+size/2, 0+size/2, 0-size/2);
			tex(t+16, t2+16);			glVertex3f(0+size/2, 0-size/2, 0-size/2);
			tex(t, t2+16);			glVertex3f(0-size/2, 0-size/2, 0-size/2);
	    	
			tex(t, t2);			glVertex3f(0-size/2, 0+size/2, 0+size/2);
			tex(t+16, t2);			glVertex3f(0-size/2, 0+size/2, 0-size/2);
			tex(t+16, t2+16);			glVertex3f(0+size/2, 0+size/2, 0-size/2);
			tex(t, t2+16);			glVertex3f(0+size/2, 0+size/2, 0+size/2);
			
			tex(t, t2);			glVertex3f(0-size/2, 0-size/2, 0+size/2);
			tex(t+16, t2);			glVertex3f(0-size/2, 0-size/2, 0-size/2);
			tex(t+16, t2+16);			glVertex3f(0+size/2, 0-size/2, 0-size/2);
			tex(t, t2+16);			glVertex3f(0+size/2, 0-size/2, 0+size/2);
			
			glEnd();
		}
}
